//! \file Db.cpp
//! \brief TODO: Document
// -----------------------------------------------------------------------------
//! This program is free software; you can redistribute it and/or
//! modify it under the terms of the GNU General Public License
//! as published by the Free Software Foundation; either version 2
//! of the License, or (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program; if not, write to the Free Software Foundation,
//! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// -----------------------------------------------------------------------------
#include "Db.h"
#include <stdlib.h>

namespace DB {

static sqlite3* m_pDb = NULL;

// =============================================================================
// Start
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
tERROR Start(void)
{
//  int Result; TODO: housekeeping

  // Initialize the SQL server.
  if (sqlite3_initialize() != 0)
    return (Stop(dERROR_FAILED_TO_START));

  // Open the SQL database for use.
  if (sqlite3_open("Test.db", &m_pDb) != 0)
    return (Stop(dERROR_FAILED_TO_START));

//  // TODO: turn into iteration table.
//  _DbEnum_Initialize(pDb); TODO: restore

  // Finally, return success.
  return (ERR_NONE);
}


// =============================================================================
// Stop
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
tERROR Stop(tERROR Error)
{
  // Close the data base.
  sqlite3_close(m_pDb);

  // Shutdown the SQL server.
  sqlite3_shutdown();

//  // Log the stop error code.
//  Core_LogError(Error); TODO: something...

  // Finally, return error code.
  return (Error);
}

} // namespace DB

//
//  sqlite3* DB::m_pDb = NULL;
//
//  // =============================================================================
//  // Start
//  // -----------------------------------------------------------------------------
//  //! TODO: document
//  //!
//  //! \param [in] Arg
//  //!   TODO: document
//  //!
//  //! \retval Exception
//  //!   The success status of the requested operation.
//  //!   - eOKAY: Execution occurred as requested.
//  //!   .
//  //!
//  //! \b Example: \code
//  //! FxName(0);
//  //! \endcode
//  // -----------------------------------------------------------------------------
//  tDB_ERROR DB::Start(void)
//  {
//    int Result;
//
//    // Initialize the SQL server.
//    if (sqlite3_initialize() != 0)
//      return (Stop(dDB_ERROR_FAILED_TO_START));
//
//    // Open the SQL database for use.
//    if (sqlite3_open("Test.db", &m_pDb) != 0)
//      return (Stop(dDB_ERROR_FAILED_TO_START));
//
//  //  // TODO: turn into iteration table.
//  //  _DbEnum_Initialize(pDb); TODO: restore
//
//    // Finally, return success.
//    return (dDB_NO_ERROR);
//  }
//
//
//  // =============================================================================
//  // Stop
//  // -----------------------------------------------------------------------------
//  //! TODO: document
//  //!
//  //! \param [in] Arg
//  //!   TODO: document
//  //!
//  //! \retval Exception
//  //!   The success status of the requested operation.
//  //!   - eOKAY: Execution occurred as requested.
//  //!   .
//  //!
//  //! \b Example: \code
//  //! FxName(0);
//  //! \endcode
//  // -----------------------------------------------------------------------------
//  tDB_ERROR DB::Stop(tDB_ERROR Error)
//  {
//    // Close the data base.
//    sqlite3_close(m_pDb);
//
//    // Shutdown the SQL server.
//    sqlite3_shutdown();
//
//  //  // Log the stop error code.
//  //  Core_LogError(Error); TODO: something...
//
//    // Finally, return error code.
//    return (Error);
//  }

//
//  // =====[ Local Definitions ]===================================================
//
//  // =====[ Local DataTypes ]=====================================================
//
//  // =====[ Local Variables ]=====================================================
//
//  // =====[ Local Functions ]=====================================================
//
//  // =====[ Private (Internal) Methods ]==========================================
//
//  // =====[ Local Implementation ]================================================
//
//  #include "Db.h"
//
//  Db::Db()
//  {
//    // TODO Auto-generated constructor stub
//
//  }
//
//  Db::~Db()
//  {
//    // TODO Auto-generated destructor stub
//  }
